package com.dmc.hrl.controller;

import com.dmc.hrl.domain.entity.Result;
import com.dmc.hrl.domain.entity.ResultEntity;
import com.dmc.hrl.domain.model.HomeContent;
import com.dmc.hrl.domain.model.ShopCart;
import com.dmc.hrl.service.ShopCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api( tags = {"购物车"}, description = "购物车测试模块")
@CrossOrigin
@RequestMapping("/shop")
public class ShopCartController
{
    @Autowired
    private ShopCartService shopCartService;

    @RequestMapping(value = "/queryGoodsByName",method = RequestMethod.POST,params="name")
    @ApiOperation(value="通过名称查询商品数据",notes = "通过名称查询商品数据")
    public Result<ShopCart> queryGoodsByName(String name){
        return ResultEntity.ok(shopCartService.queryGoodsByName(name));
    }

    @RequestMapping(value = "/queryGoods",method = RequestMethod.POST,params = "id")
    @ApiOperation(value = "通过ID查询商品数据", notes = "通过ID查询商品数据")
    public Result<ShopCart> queryGoods(@RequestParam("id") Integer id){
        System.out.print("queryGoods = "+id);
        return  ResultEntity.ok(shopCartService.queryGoods(id));
    }
}
